{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bd62db69-25b7-4166-9bf3-14b6f10c5d72",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9\n",
      "{'s01': ['马丁', '意大利', 3.1], 's02': ['托马斯', '西班牙', 2.8], 's03': ['理查德', '挪威', 2.7], 's04': ['西蒙', '英国', 3], 's05': ['乔治', '法国', 2.8], 's06': ['杰瑞', '荷兰', 2.6], 's07': ['艾伯特', '比利时', 2.5], 's08': ['马丁', '瑞士', 2]}\n"
     ]
    }
   ],
   "source": [
    "from openpyxl import load_workbook\n",
    "\n",
    "wb = load_workbook('./选手信息.xlsx')\n",
    "sheet_name = wb.sheetnames[0]\n",
    "ws = wb[sheet_name]\n",
    "print(wb[sheet_name].max_row)\n",
    "xs_dic = {}  #创建xs_dic这个字典\n",
    "for row in range(2,wb[sheet_name].max_row+1):\n",
    "    #row = 2\n",
    "    xs_list = []  #初始化xs_list\n",
    "    xs_list.append(ws['A' + str(row)].value)\n",
    "    xs_list.append(ws['B' + str(row)].value)\n",
    "    xs_list.append(ws['C' + str(row)].value)\n",
    "    xs_list.append(ws['D' + str(row)].value)\n",
    "    #print(row)\n",
    "#print(xs_list)\n",
    "#print(row)\n",
    "    key = xs_list[0]  #把键初始化为0\n",
    "    #print(key)\n",
    "    xs_dic[key] = xs_list[1:4] #给字典一个值，这个值从key里取，且值和xs_list一样\n",
    "print(xs_dic)  #输出字典的值\n",
    "#print(key)\n",
    "#print(xs_dic[key][2]) #不能写成xs_dic.key[0].value\n",
    "#print(xs_dic)\n",
    "#print(wb[sheet_name].max_row+1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e161736d-e1e4-4383-b2cb-6e37eb62f216",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "WindsorWu",
   "language": "python",
   "name": "windsorwu"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
